<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>商品修改</title>
    <link rel="stylesheet"  type="text/css" href="/css/reset.css">
    <link rel="stylesheet"  type="text/css" href="/css/main.css">
    <script type="text/javascript" src="/js/jquery-1.12.4.min.js"></script>
    <script type="text/javascript" src="/js/jquery.form.min.js"></script>
    <script type="text/javascript" src="/js/user_index_commodity.js"></script>
</head>
<body class="base_background">
    <div class="base">
        <div class="base_info">
            <h3>商品修改</h3>
        </div>
        <div class="base_content">
            <form class="update_commodity_form">
                <div>
                    <label>名称：</label>
                    <input type="text" name="commodity_name" id="commodity_name" value="{{commodity_name}}">
                </div>
                <div>
                    <label>分类：</label>
                    <select name="classify_id" id="classify_id">
                        {{each classify}}
                        {{if $value.classify_id==classify_id}}
                        <option value="{{$value.classify_id}}" selected="selected">{{$value.classify_name}}</option>
                        {{else}}
                        <option value="{{$value.classify_id}}">{{$value.classify_name}}</option>
                        {{/if}}
                        {{/each}}
                    </select>
                </div>
                <div>
                    <label>单价(元)：</label>
                    <input type="number" name="unit_price" id="unit_price" value="{{unit_price}}" step="0.01" min="0">
                </div>
                <div>
                    <label>简介：</label>
                    <textarea name="abstract" id="abstract" cols="30" rows="10">{{abstract2}}</textarea>
                </div>
                <div><label>上传图片（上传比例 1:1）：</label>
                    <input type="file" name="avatar_img" class="input_file"  id="upload_file" onchange="changepic(this)">
                    <script>
                        function changepic(){
                            //实现图片预览效果的js
                            var reads = new FileReader();
                            f = document.getElementById('upload_file').files[0];
                            reads.readAsDataURL(f);
                            reads.onload = function(e) {
                                document.getElementById('now_user_pic').src = this.result;
                            };
                        };
                    </script>
                    <img src="{{commodity_url}}" alt="" class="now_user_pic" id="now_user_pic">
                </div>
                <input type="hidden" name="merchant_id" value="{{merchant_id}}">
                <input type="hidden" name="commodity_id" value="{{commodity_id}}">
                <div>
                    <a href="/user_index_commodity_management/" class="off_update">返回</a>
                    <button type="submit">保存</button>
                </div>
            </form>
        </div>
    </div>
</body>
</html>